#ifndef YK_PURCHASE_PLAN_H
#define YK_PURCHASE_PLAN_H

#include <QWidget>
#include <QSqlQuery>
#include <QMap>
#include <QSqlQueryModel>
#include <QSqlRecord>
#include "pub_pop_get_item.h"
#include "pub_pop_delay.h"
#include "ys_cap_setup.h"
#include <QCamera>
#include <QCameraViewfinder>
#include <QCameraImageCapture>
#include <QCameraInfo>
#include <QGraphicsView>
#include <QGraphicsScene>
#include <QGraphicsPixmapItem>

namespace Ui {
class Yk_purchase_plan;
}

class Yk_purchase_plan : public QWidget
{
    Q_OBJECT

public:
    explicit Yk_purchase_plan(QWidget *parent = nullptr);
    ~Yk_purchase_plan();

    void closeEvent(QCloseEvent *event);

signals:
    void destroyW( QString );

private slots:
    void on_pb_exit_clicked();

    void on_pb_search_clicked();

    void change_lock_status(bool);

    void on_le_key_returnPressed();

    void on_tv_source_clicked(const QModelIndex &index);

    void on_pb_add_clicked();

    void on_pb_save_clicked();

    void showList();

    bool checkStatus(QString mod);

    void calc_amount();

    void on_le_purch_price_textChanged(const QString &arg1);

    void on_le_in_num_textChanged(const QString &arg1);

    bool ins_input(QSqlRecord, QMap<QString,QString>);

    void on_le_batch_no_returnPressed();

    void on_le_produced_date_returnPressed();

    void on_le_valid_date_returnPressed();

    void on_le_purch_price_returnPressed();

    void on_tv_in_list_clicked(const QModelIndex &index);

    void on_pb_unlock_status_clicked();

    void on_pb_search_2_clicked();

    void on_le_key_browse_returnPressed();

    void on_pb_check_search_clicked();

    QStringList get_search_sql();

    void on_pb_cap_take_clicked();

    void on_pb_cap_setup_clicked();

    void on_cbb_cam_id_currentTextChanged(const QString &arg1);

    void on_pb_cap_remove_clicked();

    void on_pb_pic_save_clicked();

    void on_pb_pic_refresh_clicked();

    void on_tv_pic_display_doubleClicked(const QModelIndex &index);

    void on_tv_pic_display_clicked(const QModelIndex &index);

    void on_pb_pic_upload_clicked();

    void on_pb_pic_describe_change_clicked();

    void pic_fitToView();
    void pic_zoomIn();
    void pic_zoomOut();

    bool remote_file_syncronize(QString, QString);
    void cameraImageCaptured(int, QImage image);

    void change_camera(QString);
    void camera_initial();

    void on_pb_camera_initial_clicked();

    void on_pb_get_pic_clicked();

    void on_pb_fresh_check_record_clicked();

    void on_tv_check_list_doubleClicked(const QModelIndex &index);

    void on_lw_selected_doubleClicked(const QModelIndex &index);

    void set_store_type();

    void on_rb_pha_clicked();

    void on_rb_mat_clicked();

    void on_pb_set_pay_flag_clicked();

private:
    Ui::Yk_purchase_plan *ui;

    QSqlQuery *qrm, *qro, *qrot;

    QSqlQueryModel *md_pics;//图像
    QSqlQueryModel *md_search_pop;//
    QSqlQueryModel *md_search_list, *md_in_list;
    QSqlQueryModel *md_check_list, *md_check_to_take_pic;

    QMap<QString,QString> mpRecipeItemInfo; //手工录入处方，存储中间值

    Pub_pop_get_item * dlgGetItem;
    Pub_pop_delay * dlgDelay;
    Ys_cap_setup * cap_setup;

    //QSqlQueryModel mdList ;//
    QString sq;


    //科室、代码  ，  出入模式、代码,  经销公司、代码， 生产厂、代码， 门诊用药科室、代码
    QString store_depts, mode_code_r, mode_code_c,company_code, producer_code, drug_consume_depts;
    //药品包装单位, 最小单位, 剂量单位，系统类别， 药品属性, 药品类别, 药品等级
    QString pack_units, min_units, dose_units, sys_class, drug_quality, drug_type, item_grade;
    //费用类别, 药品剂型, 医师职级
    QString fee_code, dose_models, duty_constrains;

    bool initialFinished;

    QMap<QString,QString> item_detail;  //当前选中的项目内容

    QCamera * camera;
    QCameraViewfinder * viewfinder;
    QCameraImageCapture* imageCapture;

    bool camera_initialized;

    bool has_camera;

    int pic_num;

    QMap<QString, QString> pic_describe;

    QString remote_path, pic_path;
    QString current_pic_company;

    QGraphicsView * view;
    QGraphicsScene * scene;
    QGraphicsPixmapItem *pixmapItem;

    double pic_scale_factor;

    bool state_pha, state_mat, has_edited;
};

#endif // YK_PURCHASE_PLAN_H
